/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.me.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Jayasundara
 */
@Entity
@Table(name = "versions", catalog = "postgres", schema = "public")
@NamedQueries({@NamedQuery(name = "Versions.findAll", query = "SELECT v FROM Versions v"), @NamedQuery(name = "Versions.findById", query = "SELECT v FROM Versions v WHERE v.id = :id"), @NamedQuery(name = "Versions.findByName", query = "SELECT v FROM Versions v WHERE v.name = :name"), @NamedQuery(name = "Versions.findByReleaseDate", query = "SELECT v FROM Versions v WHERE v.releaseDate = :releaseDate")})
public class Versions implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "name", length = 15)
    private String name;
    @Column(name = "release_date")
    @Temporal(TemporalType.DATE)
    private Date releaseDate;
    @JoinColumn(name = "component_id", referencedColumnName = "id")
    @ManyToOne
    private Component componentId;
    @OneToMany(mappedBy = "versionId")
    private List<FixVersion> fixVersionCollection;
    @OneToMany(mappedBy = "versionId")
    private List<AffectedVersions> affectedVersionsCollection;

    public Versions() {
    }

    public Versions(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getReleaseDate() {
        return releaseDate;
    }

    public void setReleaseDate(Date releaseDate) {
        this.releaseDate = releaseDate;
    }

    public Component getComponentId() {
        return componentId;
    }

    public void setComponentId(Component componentId) {
        this.componentId = componentId;
    }

    public List<FixVersion> getFixVersionCollection() {
        return fixVersionCollection;
    }

    public void setFixVersionCollection(List<FixVersion> fixVersionCollection) {
        this.fixVersionCollection = fixVersionCollection;
    }

    public List<AffectedVersions> getAffectedVersionsCollection() {
        return affectedVersionsCollection;
    }

    public void setAffectedVersionsCollection(List<AffectedVersions> affectedVersionsCollection) {
        this.affectedVersionsCollection = affectedVersionsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Versions)) {
            return false;
        }
        Versions other = (Versions) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.me.entity.Versions[id=" + id + "]";
    }

}
